package com.g8.pethospitallearnbackend.mapper;

import com.g8.pethospitallearnbackend.entity.Vaccine;
import com.g8.pethospitallearnbackend.entity.VaccineExample;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface VaccineMapper {
    @SelectProvider(type=VaccineSqlProvider.class, method="countByExample")
    long countByExample(VaccineExample example);

    @DeleteProvider(type=VaccineSqlProvider.class, method="deleteByExample")
    int deleteByExample(VaccineExample example);

    @Delete({
        "delete from vaccine",
        "where vaccine_id = #{vaccineId,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String vaccineId);

    @Insert({
        "insert into vaccine (vaccine_id, vaccine_name, ",
        "vaccine_price, vaccine_desc)",
        "values (#{vaccineId,jdbcType=VARCHAR}, #{vaccineName,jdbcType=VARCHAR}, ",
        "#{vaccinePrice,jdbcType=DOUBLE}, #{vaccineDesc,jdbcType=LONGVARCHAR})"
    })
    int insert(Vaccine record);

    @InsertProvider(type=VaccineSqlProvider.class, method="insertSelective")
    int insertSelective(Vaccine record);

    @SelectProvider(type=VaccineSqlProvider.class, method="selectByExampleWithBLOBs")
    @Results({
        @Result(column="vaccine_id", property="vaccineId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="vaccine_name", property="vaccineName", jdbcType=JdbcType.VARCHAR),
        @Result(column="vaccine_price", property="vaccinePrice", jdbcType=JdbcType.DOUBLE),
        @Result(column="vaccine_desc", property="vaccineDesc", jdbcType=JdbcType.LONGVARCHAR)
    })
    List<Vaccine> selectByExampleWithBLOBs(VaccineExample example);

    @SelectProvider(type=VaccineSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="vaccine_id", property="vaccineId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="vaccine_name", property="vaccineName", jdbcType=JdbcType.VARCHAR),
        @Result(column="vaccine_price", property="vaccinePrice", jdbcType=JdbcType.DOUBLE)
    })
    List<Vaccine> selectByExample(VaccineExample example);

    @Select({
        "select",
        "vaccine_id, vaccine_name, vaccine_price, vaccine_desc",
        "from vaccine",
        "where vaccine_id = #{vaccineId,jdbcType=VARCHAR}"
    })
    @Results({
        @Result(column="vaccine_id", property="vaccineId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="vaccine_name", property="vaccineName", jdbcType=JdbcType.VARCHAR),
        @Result(column="vaccine_price", property="vaccinePrice", jdbcType=JdbcType.DOUBLE),
        @Result(column="vaccine_desc", property="vaccineDesc", jdbcType=JdbcType.LONGVARCHAR)
    })
    Vaccine selectByPrimaryKey(String vaccineId);

    @UpdateProvider(type=VaccineSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Vaccine record, @Param("example") VaccineExample example);

    @UpdateProvider(type=VaccineSqlProvider.class, method="updateByExampleWithBLOBs")
    int updateByExampleWithBLOBs(@Param("record") Vaccine record, @Param("example") VaccineExample example);

    @UpdateProvider(type=VaccineSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Vaccine record, @Param("example") VaccineExample example);

    @UpdateProvider(type=VaccineSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Vaccine record);

    @Update({
        "update vaccine",
        "set vaccine_name = #{vaccineName,jdbcType=VARCHAR},",
          "vaccine_price = #{vaccinePrice,jdbcType=DOUBLE},",
          "vaccine_desc = #{vaccineDesc,jdbcType=LONGVARCHAR}",
        "where vaccine_id = #{vaccineId,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKeyWithBLOBs(Vaccine record);

    @Update({
        "update vaccine",
        "set vaccine_name = #{vaccineName,jdbcType=VARCHAR},",
          "vaccine_price = #{vaccinePrice,jdbcType=DOUBLE}",
        "where vaccine_id = #{vaccineId,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(Vaccine record);
}